<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>现代化登录界面</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        :root {
            --primary-color: #4361ee;
            --secondary-color: #3f37c9;
            --success-color: #4cc9f0;
            --text-color: #333;
            --light-text: #f8f9fa;
            --bg-color: #f0f2f5;
            --card-bg: #ffffff;
            --shadow: rgba(0, 0, 0, 0.1);
            --input-bg: #f8f9fa;
            --border-color: #e0e0e0;
            --transition: all 0.3s ease;
        }

        .dark-mode {
            --primary-color: #4895ef;
            --secondary-color: #4361ee;
            --text-color: #f8f9fa;
            --bg-color: #121212;
            --card-bg: #1e1e1e;
            --shadow: rgba(0, 0, 0, 0.3);
            --input-bg: #2d2d2d;
            --border-color: #444;
            --light-text: #f8f9fa;
        }

        body {
            background: linear-gradient(135deg, #667eea, #764ba2);
            min-height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 20px;
            transition: var(--transition);
            position: relative;
            overflow: hidden;
        }

        /* 背景动画元素 */
        .background-animation {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
            overflow: hidden;
        }

        .bubble {
            position: absolute;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.1);
            animation: float 15s infinite linear;
        }

        @keyframes float {
            0% {
                transform: translateY(0) rotate(0deg);
                opacity: 1;
            }
            100% {
                transform: translateY(-1000px) rotate(720deg);
                opacity: 0;
            }
        }

        .login-container {
            background: var(--card-bg);
            width: 100%;
            max-width: 400px;
            border-radius: 20px;
            box-shadow: 0 15px 35px var(--shadow);
            padding: 40px;
            text-align: center;
            position: relative;
            overflow: hidden;
            z-index: 1;
            transition: var(--transition);
        }

        .login-container::before {
            content: '';
            position: absolute;
            top: -50%;
            left: -50%;
            width: 200%;
            height: 200%;
            background: linear-gradient(45deg, transparent, var(--primary-color), transparent);
            transform: rotate(0deg);
            animation: rotate 6s linear infinite;
            z-index: -1;
        }

        @keyframes rotate {
            100% {
                transform: rotate(360deg);
            }
        }

        .login-header {
            margin-bottom: 30px;
        }

        .login-header h1 {
            color: var(--primary-color);
            font-size: 28px;
            margin-bottom: 10px;
        }

        .login-header p {
            color: var(--text-color);
            font-size: 16px;
            opacity: 0.8;
        }

        .input-group {
            margin-bottom: 20px;
            text-align: left;
            position: relative;
        }

        .input-group label {
            display: block;
            margin-bottom: 8px;
            color: var(--text-color);
            font-weight: 500;
            font-size: 14px;
        }

        .input-group input {
            width: 100%;
            padding: 14px 15px 14px 45px;
            border: 2px solid var(--border-color);
            border-radius: 10px;
            background: var(--input-bg);
            color: var(--text-color);
            font-size: 16px;
            transition: var(--transition);
        }

        .input-group input:focus {
            border-color: var(--primary-color);
            outline: none;
            box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
        }

        .input-group i {
            position: absolute;
            left: 15px;
            top: 40px;
            color: var(--primary-color);
            font-size: 18px;
        }

        .remember-forgot {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 25px;
            font-size: 14px;
        }

        .remember {
            display: flex;
            align-items: center;
        }

        .remember input {
            margin-right: 8px;
            accent-color: var(--primary-color);
        }

        .remember label {
            color: var(--text-color);
        }

        .forgot-password {
            color: var(--primary-color);
            text-decoration: none;
            transition: var(--transition);
        }

        .forgot-password:hover {
            text-decoration: underline;
        }

        .login-button {
            width: 100%;
            padding: 14px;
            background: var(--primary-color);
            color: white;
            border: none;
            border-radius: 10px;
            font-size: 16px;
            font-weight: 600;
            cursor: pointer;
            transition: var(--transition);
            margin-bottom: 20px;
        }

        .login-button:hover {
            background: var(--secondary-color);
            transform: translateY(-2px);
            box-shadow: 0 7px 15px rgba(67, 97, 238, 0.3);
        }

        .login-button:active {
            transform: translateY(0);
        }

        .social-login {
            margin: 25px 0;
        }

        .social-login p {
            position: relative;
            color: var(--text-color);
            margin-bottom: 15px;
            font-size: 14px;
        }

        .social-login p::before,
        .social-login p::after {
            content: '';
            position: absolute;
            top: 50%;
            width: 30%;
            height: 1px;
            background: var(--border-color);
        }

        .social-login p::before {
            left: 0;
        }

        .social-login p::after {
            right: 0;
        }

        .social-icons {
            display: flex;
            justify-content: center;
            gap: 15px;
        }

        .social-icon {
            width: 45px;
            height: 45px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--input-bg);
            color: var(--text-color);
            font-size: 18px;
            transition: var(--transition);
            text-decoration: none;
        }

        .social-icon:hover {
            transform: translateY(-3px);
            box-shadow: 0 5px 15px var(--shadow);
        }

        .facebook:hover {
            background: #3b5998;
            color: white;
        }

        .google:hover {
            background: #dd4b39;
            color: white;
        }

        .twitter:hover {
            background: #1da1f2;
            color: white;
        }

        .signup-link {
            color: var(--text-color);
            font-size: 15px;
        }

        .signup-link a {
            color: var(--primary-color);
            text-decoration: none;
            font-weight: 600;
            transition: var(--transition);
        }

        .signup-link a:hover {
            text-decoration: underline;
        }

        .theme-toggle {
            position: absolute;
            top: 20px;
            right: 20px;
            background: var(--input-bg);
            border: none;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            transition: var(--transition);
            color: var(--text-color);
            font-size: 18px;
            box-shadow: 0 2px 10px var(--shadow);
        }

        .theme-toggle:hover {
            transform: rotate(30deg);
        }

        /* 响应式设计 */
        @media (max-width: 480px) {
            .login-container {
                padding: 30px 20px;
            }

            .login-header h1 {
                font-size: 24px;
            }

            .remember-forgot {
                flex-direction: column;
                align-items: flex-start;
                gap: 10px;
            }

            .forgot-password {
                margin-left: 28px;
            }
        }

        /* 表单验证样式 */
        .error {
            color: #e63946;
            font-size: 13px;
            margin-top: 5px;
            display: block;
            text-align: left;
        }
    </style>
</head>
<body>
<!-- 背景动画 -->
<div class="background-animation" id="background"></div>

<div class="login-container">
    <button class="theme-toggle" id="themeToggle">
        <i class="fas fa-moon"></i>
    </button>

    <div class="login-header">
        <h1>欢迎回来</h1>
        <p>请登录您的账户以继续</p>
    </div>

    <form id="loginForm" action="http://localhost:8080/v1/user/login" method="post">
        <div class="input-group">
            <label for="username">用户名</label>
            <i class="fas fa-user"></i>
            <input type="text" name="username" id="username" placeholder="请输入用户名">
            <span class="error" id="usernameError"></span>
        </div>

        <div class="input-group">
            <label for="password">密码</label>
            <i class="fas fa-lock"></i>
            <input type="password" name="password" id="password" placeholder="请输入密码">
            <span class="error" id="passwordError"></span>
        </div>

        <div class="remember-forgot">
            <div class="remember">
                <input type="checkbox" id="remember">
                <label for="remember">记住我</label>
            </div>
            <a href="#" class="forgot-password">忘记密码?</a>
        </div>
        <button type="submit" class="login-button">登录</button>
    </form>

    <div class="social-login">
        <p>或使用以下方式登录</p>
        <div class="social-icons">
            <a href="#" class="social-icon facebook">
                <i class="fab fa-facebook-f"></i>
            </a>
            <a href="#" class="social-icon google">
                <i class="fab fa-google"></i>
            </a>
            <a href="#" class="social-icon twitter">
                <i class="fab fa-twitter"></i>
            </a>
        </div>
    </div>

    <div class="signup-link">
        还没有账户? <a href="#">立即注册</a>
    </div>
</div>

<script>
    // 创建背景动画气泡
    function createBubbles() {
        const background = document.getElementById('background');
        const bubblesCount = 15;

        for (let i = 0; i < bubblesCount; i++) {
            const bubble = document.createElement('div');
            bubble.classList.add('bubble');

            // 随机大小
            const size = Math.random() * 100 + 20;
            bubble.style.width = `${size}px`;
            bubble.style.height = `${size}px`;

            // 随机位置
            bubble.style.left = `${Math.random() * 100}%`;
            bubble.style.top = `${Math.random() * 100 + 100}%`;

            // 随机动画延迟
            bubble.style.animationDelay = `${Math.random() * 15}s`;

            // 随机动画持续时间
            const duration = 10 + Math.random() * 20;
            bubble.style.animationDuration = `${duration}s`;

            background.appendChild(bubble);
        }
    }

    // 主题切换
    const themeToggle = document.getElementById('themeToggle');
    const themeIcon = themeToggle.querySelector('i');

    themeToggle.addEventListener('click', () => {
        document.body.classList.toggle('dark-mode');

        if (document.body.classList.contains('dark-mode')) {
            themeIcon.classList.remove('fa-moon');
            themeIcon.classList.add('fa-sun');
        } else {
            themeIcon.classList.remove('fa-sun');
            themeIcon.classList.add('fa-moon');
        }
    });

    // 表单验证
    const loginForm = document.getElementById('loginForm');
    const usernameInput = document.getElementById('username');
    const passwordInput = document.getElementById('password');
    const usernameError = document.getElementById('usernameError');
    const passwordError = document.getElementById('passwordError');

    loginForm.addEventListener('submit', (e) => {
        // e.preventDefault();
        let isValid = true;

        // 重置错误信息
        usernameError.textContent = '';
        passwordError.textContent = '';

        // 验证用户名
        if (usernameInput.value.trim() === '') {
            usernameError.textContent = '请输入用户名';
            isValid = false;
            usernameInput.focus();
        }

        // 验证密码
        if (passwordInput.value.trim() === '') {
            passwordError.textContent = '请输入密码';
            isValid = false;
            if (usernameInput.value.trim() !== '') {
                passwordInput.focus();
            }
        } else if (passwordInput.value.length < 3) {
            passwordError.textContent = '密码长度至少为3个字符';
            isValid = false;
            passwordInput.focus();
        }

        // 如果表单有效，显示登录成功消息
        if (isValid) {
            // 这里通常会有AJAX请求
            alert('登录成功！即将跳转至仪表盘...');
            // loginForm.reset();
        }
    });
    // 初始化背景动画
    createBubbles();
</script>
</body>
</html>